package com.mixsmart.commonweb.bean.entity;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

import org.hibernate.annotations.DynamicUpdate;

import com.mixsmart.commonweb.bean.ICreateTime;
import com.mixsmart.commonweb.bean.ISelfClassAssert;
import com.mixsmart.commonweb.enums.OrgType;
import com.mixsmart.enums.YesNoType;

/**
 * 组织机构--实体
 * @author lmq
 * @version 1.0
 * @since JDK版本大于等于1.6
 * 2016年2月1日
 */
@Entity
@Table(name="t_c_org")
@DynamicUpdate(true)
public class TCOrg implements ISelfClassAssert<TCOrg>, ICreateTime {

	/**
	 * 
	 */
	private static final long serialVersionUID = -926827245619202457L;

	private String id;
	
	private String name;
	
	private String serialName;
	
	private String parentId;
	
	private Integer sortNum = 0;
	
	private String code;
	
	private String serialCode;
	
	private Integer state = YesNoType.YES.getIndex();
	
	/**
	 * 类型：org -- 机构;
	 * department --部门   
	 */
	private String type = OrgType.ORG.getValue();
	
	private Integer level = 0;
	
	private Boolean isLeaf = true;
	
	private Date createTime;

	
	/////getter and setter/////
	@Id
	@Column(name="id", length=50)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name="name", length=127, nullable=false)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@Column(name="serial_name", length=500)
	public String getSerialName() {
		return serialName;
	}

	public void setSerialName(String serialName) {
		this.serialName = serialName;
	}

	@Column(name="parent_id", length=50)
	public String getParentId() {
		return parentId;
	}

	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	@Column(name="sort_num")
	public Integer getSortNum() {
		return sortNum;
	}

	public void setSortNum(Integer sortNum) {
		this.sortNum = sortNum;
	}

	@Column(name="code", length=127, nullable=false)
	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	@Column(name="serial_code",length=500)
	public String getSerialCode() {
		return serialCode;
	}

	public void setSerialCode(String serialCode) {
		this.serialCode = serialCode;
	}
	
	@Column(name="state", length=2)
	public Integer getState() {
		return state;
	}

	public void setState(Integer state) {
		this.state = state;
	}

	@Column(name="level_", nullable=false)
	public Integer getLevel() {
		return level;
	}

	public void setLevel(Integer level) {
		this.level = level;
	}

	@Column(name="is_leaf")
	public Boolean getIsLeaf() {
		return isLeaf;
	}

	public void setIsLeaf(Boolean isLeaf) {
		this.isLeaf = isLeaf;
	}
	
	@Column(name="type", length=50, nullable=false)
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	@Temporal(TemporalType.TIMESTAMP)
	@Column(name="create_time", updatable=false)
	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	@Override
	public void assertValue(TCOrg org) {
		if(null != org) {
			this.code = org.getCode();
			this.level = org.getLevel();
			this.name = org.getName();
			this.parentId = org.getParentId();
			this.serialCode = org.getSerialCode();
			this.serialName = org.getSerialName();
			this.sortNum = org.getSortNum();
			this.type = org.getType();
			this.state = org.getState();
		}	
	}
}
